﻿@model PagedList<RBS.Core.Model.U_Friends>
@using RBS.Core.Model
@using Webdiyer.WebControls.Mvc
@{
    ViewBag.Title = "邀请好友";
    Layout = "~/Views/Shared/_Layout.cshtml";

    var orderid = Request["orderid"];
}
<script>
    $(function () {
        $("#btnInvite").click(function () {
            var f_str = "";
            $(".ltable :checkbox[id='chkId']").each(function () {
                if (this.checked && this.value != "undefined") {
                    f_str += this.value + ',';
                }
            });
            $.dialog.confirm("确定邀请这几位好友就餐吗？", function () {
                var url = '@Url.Action("InviteFriend")?ids=' + f_str+"&orderid="+@orderid;
                $.ajax({
                    url: url,
                    type: "post",
                    dataType: 'json', 
                    success: function (data) {
                        if (data.IsSuccess) {
                            location.replace(location.href);
                        }
                        else { 
                            $.dialog.alert(data.Msg);
                        }
                    }
                });
            });
            return false;
        }); 
    }); 
    function OnSuccess(e) { 
        location.replace(location.href);
    }
</script> 
<!--/导航栏-->
<!--工具栏-->
<div class="toolbar-wrap">
    <div id="floatHead" class="toolbar">
        <div class="l-list">
            <ul class="icon-list"> 
                <li><a class="all" href="javascript:;" onclick="checkAll(this);"><i></i><span>全选</span></a></li>
                <li>
                    <a id="btnInvite" class="del" href="#"><i></i><span>邀请</span></a>
                </li>
            </ul>
        </div>
        <div class="r-list">
            @using (Html.BeginForm("Invite", "Order", new RouteValueDictionary { { "id", "" } }, FormMethod.Get))
            {
                <input id="kword" name="kword" type="text" class="keyword" value="@Request.QueryString["kword"]"/>
                <input type="submit" value="查询" class="btn-search" accesskey="S" /> 
            }
        </div>
    </div>
</div>
<!--/工具栏-->
<div class="tbllist">
<!--列表-->
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
    <tr>
        <th width="8%">选择</th>  
        <th align="left">姓名</th>
        <th align="left">手机</th>
        <th align="left">状态</th>
    </tr>
    @if (null != ViewData.Model)
    {
        List<RBS.Core.Model.D_Guest> gusetList = new RBS.Core.BLL.D_Guest().GetModelList(" OrderId=" + orderid);
        var findguset = new D_Guest();
        foreach (var item in ViewData.Model)
        {
            var user = new RBS.Core.BLL.U_User().GetModelByCache(item.FriendId);
            <tr>
                <td align="center">
                     @if (gusetList.Any())
                    {
                        findguset = gusetList.FirstOrDefault(c => c.GuestId == item.FriendId);
                        if (findguset == null )
                        {
                                 <input type="checkbox" id="chkId" value="@item.FriendId" class="checkall" style="vertical-align: middle;" />
                                 <input id="hidId" type="hidden" value="@item.FriendId"/>  
                        }
                    }
                    else
                    { 
                        <input type="checkbox" id="chkId" value="@item.FriendId" class="checkall" style="vertical-align: middle;" />
                        <input id="hidId" type="hidden" value="@item.FriendId"/>
                    } 
                </td>   
                <td align="left">
                    @item.FriendId  @(user.U_Name)
                </td> 
                <td align="left">
                  @(user.Mobile)
                </td>
                <td align="left">
                   @if (findguset != null)
                   {
                       if (findguset.Status == 0)
                       {
                            @Ajax.ActionLink("取消","GuestCancel",new{ids=findguset.Id}, new AjaxOptions{OnSuccess ="OnSuccess",HttpMethod = "Post"})
                       }
                       else
                       {
                             if (findguset.Status == 1)
                             {
                                            @Html.Raw("参加")
                             }
                             else if (findguset.Status == 2)
                             {
                                             @Html.Raw("不参加")
                                             @Html.Raw("</br>【" + findguset.Remark + "】")                            
                                
                             }
                       }
                   }
                </td>
            </tr>
        }
    }
</table>
     </div>
<!--/列表-->
<!--内容底部-->
 
<div class="pagelist">
    <div class="l-btns">
        <span>显示</span> <span>10 条/页</span><span>共 @Model.TotalPageCount 页 @Model.TotalItemCount 条记录，当前为第 @Model.CurrentPageIndex 页</span>
    </div>
    @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", ShowPageIndexBox = true, PageIndexBoxType = PageIndexBoxType.DropDownList, ShowGoButton = false, CurrentPagerItemWrapperFormatString = "<span class=\"current\">{0}</span>" }, new { id = "PageContent", @class = "default" })
    @section Scripts{@{Html.RegisterMvcPagerScriptResource();}}
</div>
<!--/内容底部-->


